/**
 *
 * @author mweya
 */
import montecarlooop.Point;
import java.lang.Math;
public class MonteCarloOOP {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int times_to_run = 10000;
        double area = 0;
        double radius = 0.5;
        int incircle = 0;
        
        int j = 0;
        while (j<times_to_run){
            Point p = new Point();
            if (isInCircle(p, radius)) {
                incircle = incircle+1;
            }
            j = j+1;
        }
        
        // This is an estimation of the area
        // Times it by 1.0 to make it a double
        area = incircle*1.0/times_to_run*1.0;
        double estimated_pi = 0;
        estimated_pi = area/(radius*radius);
        System.out.println(estimated_pi);
    }
    
    public static boolean isInCircle(Point p, double radius){
        double distance = Math.sqrt((p.x-radius)*(p.x-radius)+(p.y-radius)*(p.y-radius));
        if (distance<radius){
            return true;
        }
        return false;
    }
    
}